package org.yourscrum.web;

privileged aspect StoryController_Roo_Controller {
    
    @org.springframework.web.bind.annotation.RequestMapping(value = "/story", method = org.springframework.web.bind.annotation.RequestMethod.POST)    
    public java.lang.String StoryController.create(@org.springframework.web.bind.annotation.ModelAttribute("story") org.yourscrum.domain.Story story, org.springframework.validation.BindingResult result) {    
        if (story == null) throw new IllegalArgumentException("A story is required");        
        for(javax.validation.ConstraintViolation<org.yourscrum.domain.Story> constraint : javax.validation.Validation.buildDefaultValidatorFactory().getValidator().validate(story)) {        
            result.rejectValue(constraint.getPropertyPath(), null, constraint.getMessage());            
        }        
        if (result.hasErrors()) {        
            return "story/create";            
        }        
        story.persist();        
        return "redirect:/story/" + story.getId();        
    }    
    
    @org.springframework.web.bind.annotation.RequestMapping(value = "/story/form", method = org.springframework.web.bind.annotation.RequestMethod.GET)    
    public java.lang.String StoryController.createForm(org.springframework.ui.ModelMap modelMap) {    
        modelMap.addAttribute("story", new org.yourscrum.domain.Story());        
        modelMap.addAttribute("comments", org.yourscrum.domain.Comment.findAllComments());        
        modelMap.addAttribute("tasks", org.yourscrum.domain.Task.findAllTasks());        
        modelMap.addAttribute("themes", org.yourscrum.domain.Theme.findAllThemes());        
        return "story/create";        
    }    
    
    @org.springframework.web.bind.annotation.RequestMapping(value = "/story/{id}", method = org.springframework.web.bind.annotation.RequestMethod.GET)    
    public java.lang.String StoryController.show(@org.springframework.web.bind.annotation.PathVariable("id") Long id, org.springframework.ui.ModelMap modelMap) {    
        if (id == null) throw new IllegalArgumentException("An Identifier is required");        
        modelMap.addAttribute("story", org.yourscrum.domain.Story.findStory(id));        
        return "story/show";        
    }    
    
    @org.springframework.web.bind.annotation.RequestMapping(value = "/story", method = org.springframework.web.bind.annotation.RequestMethod.GET)    
    public java.lang.String StoryController.list(org.springframework.ui.ModelMap modelMap) {    
        modelMap.addAttribute("stories", org.yourscrum.domain.Story.findAllStories());        
        return "story/list";        
    }    
    
    @org.springframework.web.bind.annotation.RequestMapping(method = org.springframework.web.bind.annotation.RequestMethod.PUT)    
    public java.lang.String StoryController.update(@org.springframework.web.bind.annotation.ModelAttribute("story") org.yourscrum.domain.Story story, org.springframework.validation.BindingResult result) {    
        if (story == null) throw new IllegalArgumentException("A story is required");        
        for(javax.validation.ConstraintViolation<org.yourscrum.domain.Story> constraint : javax.validation.Validation.buildDefaultValidatorFactory().getValidator().validate(story)) {        
            result.rejectValue(constraint.getPropertyPath(), null, constraint.getMessage());            
        }        
        if (result.hasErrors()) {        
            return "story/update";            
        }        
        story.merge();        
        return "redirect:/story/" + story.getId();        
    }    
    
    @org.springframework.web.bind.annotation.RequestMapping(value = "/story/{id}/form", method = org.springframework.web.bind.annotation.RequestMethod.GET)    
    public java.lang.String StoryController.updateForm(@org.springframework.web.bind.annotation.PathVariable("id") java.lang.Long id, org.springframework.ui.ModelMap modelMap) {    
        if (id == null) throw new IllegalArgumentException("An Identifier is required");        
        modelMap.addAttribute("story", org.yourscrum.domain.Story.findStory(id));        
        modelMap.addAttribute("comments", org.yourscrum.domain.Comment.findAllComments());        
        modelMap.addAttribute("tasks", org.yourscrum.domain.Task.findAllTasks());        
        modelMap.addAttribute("themes", org.yourscrum.domain.Theme.findAllThemes());        
        return "story/update";        
    }    
    
    @org.springframework.web.bind.annotation.RequestMapping(value = "/story/{id}", method = org.springframework.web.bind.annotation.RequestMethod.DELETE)    
    public java.lang.String StoryController.delete(@org.springframework.web.bind.annotation.PathVariable("id") java.lang.Long id) {    
        if (id == null) throw new IllegalArgumentException("An Identifier is required");        
        org.yourscrum.domain.Story.findStory(id).remove();        
        return "redirect:/story";        
    }    
    
}
